
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script src="<%=request.getContextPath()%>/statics/zTree_v3/js/jquery-1.4.4.min.js"></script>
</head>
<body>
    <form id="form" method="post" action="">
        <c:forEach items="${roleBeansList}" var="roleBean" >
            <input type="checkbox" ${roleBean.checked } value="${roleBean.role.id}" name="userRole" />${roleBean.role.name}
        </c:forEach>
        <input type="button" value="分配角色" id="sub"/>
    </form>

    <script>
        $("#sub").click(function(){
            $.ajax({
                url:"<%=request.getContextPath()%>/user/assignRole.html?userId=${userId}",
                type:"post",
                data:$("#form").serialize(),
                success:function (data) {
                    if(data){
                        alert("分配成功");
                    }else {
                        alert("分配失败");
                    }
                }
            })
        })
    </script>
</body>
</html>
